package com.example.boot.test.demo.configuration;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
//定义mapper接口包路径
@MapperScan("com.example.boot.test.demo.mapper")
public class MybatisConfiguration {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();

        //设置分页拦截器（系统中需要自动进行查询分页必须设置）
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
       //每页显示多少页的条数
        paginationInnerInterceptor.setMaxLimit(2L);

        mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
        return mybatisPlusInterceptor;
    }

}